import fs from 'fs';


async function rename(filePath: string, newFilePath: string) {
    return new Promise((resolve, reject) => {
        if (fs.existsSync(newFilePath)) {
            resolve(['文件已存在', false]);
        } else {
            fs.promises.rename(filePath, newFilePath).then(() => {
                resolve([null, true]);
            }).catch((err: any) => {
                resolve([err, false]);
            })
        }


    })
}

export default rename